{template 'public/header'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_gjw/template/public/ygcss.css">
<style type="text/css">
    .storeset{border-bottom: 1px solid #eee;padding-bottom: 10px;}
    .storesetfont{font-size: 14px;font-weight: bold;}
    .ygstoreimg>.input-group:nth-child(1){float: left;width: 50%;margin-right: 30px;}
    .ygstoreimg>.input-group:nth-child(2){float: left;width: 50px;}
    .btn{padding: 7px 12px;}
    .ygstoreimg>.input-group:nth-child(2)>img{width: 45px;height: 35px;margin-top: -7px;}
    .wyheader{height: 40px;}
</style>
<style type="text/css">
    .ygmargin{margin-top: 10px;color: #999;}
    input[type="radio"] + label::before {
        content: "\a0"; /*不换行空格*/
        display: inline-block;
        vertical-align: middle;
        font-size: 16px;
        width: 1em;
        height: 1em;
        margin-right: .4em;
        border-radius: 50%;
        border: 2px solid #ddd;
        text-indent: .15em;
        line-height: 1; 
    }
    input[type="radio"]:checked + label::before {
        background-color: #44ABF7;
        background-clip: content-box;
        padding: .1em;
        border: 2px solid #44ABF7;
    }
    input[type="radio"] {
        position: absolute;
        clip: rect(0, 0, 0, 0);
    }
</style>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>    
    <li><a href="{php echo $this->createWebUrl('dbcate')}">分类列表</a></li>
    <li class="active"><a href="javascript:void(0)">添加新分类</a></li>
</ul>
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="invitative">
        <div class="panel panel-default ygdefault">
            <div class="panel-heading wyheader">
                抖宝管理&nbsp;>&nbsp;抖宝分类&nbsp;>&nbsp;添加新分类
            </div>
            <div class="panel-body">
                <input type="hidden" class="tpid" name="p_id">
                <!-- <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-sm-9">
                       <input style="width: 45%" type="text" name="sort" class="form-control" value="{$info['sort']}" />
                    </div>
                </div>  --> 
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">分类名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="cate" class="form-control" value="{$info['cate']}" />
                    </div>
                </div>
                
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">图片</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_image('img', $info['img'])}
                    <p class="dizhi">*供前端展示的分类图片;宽：高=4:3</p></a>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示</label>
                    <div class="col-sm-9">
                        <label class="radio-inline">
                            <input type="radio" id="emailwy1" name="showhide" value="1" {if $info['showhide']==1 }checked{/if} />
                            <label for="emailwy1">是</label>
                        </label>
                        <label class="radio-inline">
                            <input type="radio" id="emailwy2" name="showhide" value="0" {if $info['showhide']==0 || empty($info['showhide'])}checked{/if} />
                            <label for="emailwy2">否</label>
                        </label>    
                    </div>
                </div>
                <!-- <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">地址坐标</label>
                    <div class="col-sm-9">
                     <input type="text" name="lonlat" class="form-control dizhiname" value="{$info['lonlat']}" placeholder="例如:30.527540,114.346430" />
                     <a href="http://lbs.qq.com/tool/getpoint/" target="_blank">
                     <p class="dizhi">*点击获取地理位置</p></a>
                    </div>
                </div> -->
            </div>
        </div>


        <div class="form-group">
            <input type="submit" name="submit" value="提交" class="btn col-lg-3" style="color: white;background-color: #44ABF7;"/>
            <input type="hidden" name="token" value="{$_W['token']}" />
            <input type="hidden" name="id" value="{$info['id']}" />
        </div>
    </form>
</div>

<script type="text/javascript">
    var tpid;
    var ttid;
    $(function(){
        // $("#frame-14").addClass("in");
        $("#frame-1").show();
        $("#yframe-1").addClass("wyactive");
        var strurl=window.location.search;
        //编辑查看上级分类
        if (strurl.indexOf('tpid')!=-1) {
            tpid=window.location.search.split("tpid=")[1];
            tpid=tpid.split("&")[0];
            $(".tpid").attr("value",tpid)
            $.ajax({
                type:"get",
                url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=getedbcate&m=zh_gjw",
                dataType:"json",
                data:{pid:tpid},
                success:function(data){
                    console.log(data.cate);
                    if (data.cate) {
                        $(".tpid").after('<div class="form-group" style="margin-bottom:10px;"><label class="col-xs-12 col-sm-3 col-md-2 control-label">上级分类</label><div class="col-sm-9"><span style="line-height:28px;">'+data.cate+'</span></div></div>');
                    }
                    if (data.p_id!=0) {
                        $.ajax({
                            type:"get",
                            url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=getedbcate&m=zh_gjw",
                            dataType:"json",
                            data:{pid:data.p_id},
                            success:function(data){
                                console.log(data.cate);
                                if (data.cate) {
                                    $(".tpid").next().find("div span").prepend(data.cate+'&nbsp;&nbsp;->&nbsp;&nbsp;');
                                }
                            }
                        })
                    }
                }
            })
        }
        
        //添加查看上级分类
        if (strurl.indexOf('ttid')!=-1) {
            ttid=window.location.search.split("ttid=")[1];
            ttid=ttid.split("&")[0];
            $(".tpid").attr("value",ttid);
            $.ajax({
                type:"get",
                url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=getadbcate&m=zh_gjw",
                dataType:"json",
                data:{id:ttid},
                success:function(data){
                    console.log(data.cate);
                    if (data.cate) {
                        $(".tpid").after('<div class="form-group" style="margin-bottom:10px;"><label class="col-xs-12 col-sm-3 col-md-2 control-label">上级分类</label><div class="col-sm-9"><span style="line-height:28px;">'+data.cate+'</span></div></div>');
                    }
                    if (data.p_id!=0) {
                        $.ajax({
                            type:"get",
                            url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=getedbcate&m=zh_gjw",
                            dataType:"json",
                            data:{pid:data.p_id},
                            success:function(data){
                                console.log(data.cate);
                                if (data.cate) {
                                    $(".tpid").next().find("div span").prepend(data.cate+'&nbsp;&nbsp;->&nbsp;&nbsp;');
                                }
                            }
                        })
                    }
                }
            })
        }
    })
</script>